/*    */ package com.zimbra.cs.imap;
/*    */ 
/*    */ import org.apache.mina.filter.codec.ProtocolDecoderException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class LiteralInfo
/*    */ {
/*    */   int count;
/*    */   boolean blocking;
/*    */   
/*    */   public static LiteralInfo parse(String line)
/*    */     throws ProtocolDecoderException
/*    */   {
/* 26 */     if (line.endsWith("}")) {
/* 27 */       int i = line.lastIndexOf('{');
/* 28 */       if (i >= 0) {
/* 29 */         LiteralInfo li = new LiteralInfo();
/* 30 */         String s = line.substring(i + 1, line.length() - 1);
/* 31 */         if (s.endsWith("+")) {
/* 32 */           s = s.substring(0, s.length() - 1);
/*    */         } else {
/* 34 */           li.blocking = true;
/*    */         }
/* 36 */         li.count = parseCount(s);
/* 37 */         if (li.count < 0) {
/* 38 */           throw new NioImapDecoder.TooBigLiteralException(line);
/*    */         }
/* 40 */         return li;
/*    */       }
/*    */     }
/* 43 */     return null;
/*    */   }
/*    */   
/* 46 */   public int getCount() { return this.count; }
/* 47 */   public boolean isBlocking() { return this.blocking; }
/*    */   
/*    */   private static int parseCount(String s) {
/* 50 */     int n = 0;
/* 51 */     for (int i = 0; i < s.length(); i++) {
/* 52 */       int d = Character.digit(s.charAt(i), 10);
/* 53 */       if (d == -1) return -1;
/* 54 */       n = n * 10 + d;
/* 55 */       if (n < 0) return -1;
/*    */     }
/* 57 */     return n;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/imap/LiteralInfo.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */